import 'package:flutter/material.dart';

class ColorsUtils {
  ColorsUtils._();

  static const String colorF59a2 = '#f59a23';

  static const String colorE854 = '#E8541E';

  static const String colorC280 = '#c280ff';

  static const String colorE1e1 = '#e1e1e1';

  static const String color8080 = '#8080FF';

  static const String color2a2a = '#2a2a2a';

  static const String colorE419 = '#E41952';

  static const String color0099 = '#0099ff';

  static const String colorF26f = '#f26f51';

  static const String colorF95e = '#F95E5A';

  static const String colorF048 = '#f04864';

  static const String colorFbb8 = '#fbb8c4';

  static const String colorFfff = '#FFFFFF';

  static const String color6666 = '#666666';

  static const String color3478 = '#3478f6';

  static const String colorF7f7 = '#f7f7f7';

  static const String color3333 = '#333333';

  static const String color9999 = '#999999';

  static const String colorF2f2 = '#f2f2f2';

  static const String colorDfee = '#dfeefb';

  static const String color0000 = '#000000';

  static const String colorCccc = '#CCCCCC';

  static const String color7979 = '#797979';

  static const String colorE4e4 = '#e4e4e4';

  static const String colorB8cd = '#b8cdf6';

  static const String color6799 = '#6799F9';

  static const String colorD900 = '#D9001B';

  static const String colorF1f7 = '#f1f7fd';

  static const String colorEbf6 = '#ebf6ff';

  static const String colorEef9 = '#eef9f7';

  static const String color05b2 = '#05B288';

  static const String colorFff1 = '#fff1f1';

  static const String colorFf00 = '#FF0000';

  static const String colorF5f5 = '#f5f5f5';

  static const String colorF4F9 = '#f4f9ff';

  static const String colorFf99 = '#FF9900';

  static const String colorEaf0 = '#eaf0f6';

  static const String color5555 = '#555555';

  static const String colorEfef = '#efefef';

  static const String colorEa8e = '#EA8E05';

  static const String colorEc80 = '#EC808D';

  static const String colorF8f8 = '#f8f8f8';

  static const String colorFafa = '#fafafa';

  static const String colorAaaa = '#AAAAAA';

  static const String colorFfb8 = '#ffb800';

  static const String color841c = '#84C1F9';

  static const String colorFf52 = '#ff5252';

  static const String color09bb = '#09BB07';

  static const String colorD7d7 = '#d7d7d7';

  static const String colorFf64 = '#FF644D';

  static const String colorCc66 = '#CC6600';

  static const String color63b5 = '#63B54B';

  static const String colorFca1 = '#FCA190';

  static const String colorCc00 = '#CC0000';

  static const String colorFf6e = '#FF6E53';

  static const String colorFf66 = '#FF6600';

  static const String colorF9dc = '#f9dcd7';

  static const String colorF9f9 = '#f9f9f9';

  static const String colorFe46 = '#fe4601';

  static const String colorFff9 = '#fff9ed';

  static const String colorF660 = '#FF6010';

  static const String colorFca19 = '#fca190';

  static const String colorA9e9 = '#a9e97a';

  static const String color5151 = '#515151';

  static const String colorCc33 = '#CC3300';

  static const String color3636 = '#363636';

  static Color fromRGBO(
      [int r = 255, int g = 255, int b = 255, double opacity = 1.0]) {
    return Color.fromRGBO(r, g, b, opacity);
  }

  static Color rgba(
      [int r = 255, int g = 255, int b = 255, double opacity = 1.0]) {
    return fromRGBO(r, g, b, opacity);
  }

  static Color rgb([int r = 255, int g = 255, int b = 255]) {
    return fromRGBO(r, g, b, 1.0);
  }

  static Color parseColorFromHexString(String code) {
    Color result = Colors.red;
    int value = 0;
    if (code.contains('#')) {
      try {
        value = int.parse(code.substring(1), radix: 16);
      } catch (e) {
        debugPrint(e.toString());
      }
      switch (code.length) {
        case const (1 + 6):

          ///6位
          result = Color(value + 0xFF000000);
          break;
        case const (1 + 8):

          ///8位
          result = Color(value);
          break;
        default:
          result = Colors.red;
      }
    } else {
      try {
        value = int.parse(code, radix: 16);
      } catch (e) {
        debugPrint(e.toString());
      }
      switch (code.length) {
        case 6:
          result = Color(value + 0xFF000000);
          break;
        case 8:
          result = Color(value);
          break;
        default:
          result = Colors.red;
      }
    }
    return result;
  }

  static Color colorFromHexString(String? s) {
    return parseColorFromHexString(s ?? colorFfff);
  }

  static Color get backgroundColor {
    return colorFromHexString(colorFfff);
  }
}
